const Pool = require("../../mysql/index");

class BookDao {
  async query(sql) {
    return await Pool.query(sql);
  }
  async getAllBook() {
    let sql = "SELECT * FROM book";
    return await Pool.query(sql);
  }
  async getBookById(id) {
    let sql = `SELECT * FROM book WHERE id = ${id}`
    return await Pool.query(sql);
  }
  async getBookByKetWord(keyWord) {
    let sql = `SELECT * FROM book WHERE book.name LIKE '%${keyWord}%'`
    return await Pool.query(sql);
  }
}

module.exports = new BookDao();